package org.whuims.indritools.optmizing;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class RuleFactory {
	public List<String> rules=new ArrayList<String>();
	public Map<String,String> rulesMap=new HashMap<String,String>();
	
	public void initRules(){
		initLM_Dir_Rules();
		initLM_Linear_Rules();
		initLM_TwoStage_Rules();
		initLM_BM_Rules();
		initLM_Cos_Rules();
	}

	public void initLM_Dir_Rules() {
		for(int mu=500;mu<3000;mu+=100){
			String rule = "<rule>method:dir,mu:" + mu + "</rule>";
			rules.add(rule);
			rulesMap.put("LM_DIR:"+mu, rule);
		}
	}

	public void initLM_Linear_Rules() {
		for(double lambda=0.1;lambda<1;lambda+=0.1){
			String rule="<rule>method:linear,collectionLambda:"+lambda+"</rule>";
			rules.add(rule);
			rulesMap.put("LM_Linear:"+lambda,rule);
		}
	}

	public void initLM_TwoStage_Rules() {
		// TODO Auto-generated method stub
		
	}

	public void initLM_BM_Rules() {
		double t=0.1;
		for(double k=1.0;k<=2.5;k+=0.1){
			for(double b=0;b<=1;b+=t){
				if(b==0.6){
					t=0.05;
				}
				String rule="<baseline>method:okapi,k1:"+k+",b:"+b+",k3:7"+"</baseline>";
				rules.add(rule);
				rulesMap.put("BM25_"+k+"_"+b, rule);
			}
		}
	}

	public void initLM_Cos_Rules() {
		rules.add("<baseline>tfidf,k1:1.0,b:0.3</baseline> ");
	}
	
	public static void main(String[] args) {
		RuleFactory factory=new RuleFactory();
		factory.initRules();
		for(String s:factory.rules){
			System.out.println(s);
		}
	}

}
